package com.piggy.logi.sys.vo;

import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;

import java.math.BigDecimal;
import java.util.Date;

@Data
@NoArgsConstructor
@Accessors(chain = true)
public class LogiCustomerWayBillVo {

    /**
     * 主键
     */
    @ApiModelProperty("主键")
    @JsonFormat(shape = JsonFormat.Shape.STRING)
    private Long id;

    /**
     * 部门ID
     */
    @ApiModelProperty(value = "部门ID")
    @JsonFormat(shape = JsonFormat.Shape.STRING)
    private Long deptId;

    /**
     * 运单ID
     */
    @ApiModelProperty("运单ID")
    @JsonFormat(shape = JsonFormat.Shape.STRING)
    private Long waybillId;

    /**
     * 运单编号
     */
    @ApiModelProperty(value = "运单编号")
    private String outCode;

    /**
     * 状态：0.未结清 1.已结清
     */
    @ApiModelProperty("状态：0.未结清 1.已结清")
    private Integer status;

    /**
     * 货物名称
     */
    @ApiModelProperty("货物名称")
    private String goodsName;

    /**
     * 发货地址
     */
    @ApiModelProperty("发货地址")
    private String shipDistrictName;

    /**
     * 收货地址
     */
    @ApiModelProperty("收货地址")
    private String deliveryDistrictName;

    /**
     * 发货方名称
     */
    @ApiModelProperty("发货方名称")
    private String shipName;

    /**
     * 收货方名称
     */
    @ApiModelProperty("收货方名称")
    private String deliveryName;

    /**
     * 发货网点
     */
    @ApiModelProperty("发货网点")
    private String shipNetName;

    /**
     * 收货网点
     */
    @ApiModelProperty("收货网点")
    private String deliveryNetName;

    /**
     * 运单状态
     */
    @ApiModelProperty("运单状态")
    private Integer waybillStatus;

    /**
     * 结算模式
     */
    @ApiModelProperty("结算模式")
    private Integer settlementMode;

    /**
     * 应收总额
     */
    @ApiModelProperty("应收总额")
    private BigDecimal receivableAmount;

    /**
     * 实收金额
     */
    @ApiModelProperty("实收金额")
    private BigDecimal realAmount;

    /**
     * 应收余额
     */
    @ApiModelProperty("应收余额")
    private BigDecimal receivableBalance;

    /** 开票状态：0.未开票 1.已开票 2.开票失败 3.暂不开票 */
    @ApiModelProperty("开票状态：0.未开票 1.已开票 2.开票失败 3.暂不开票")
    @JsonFormat(shape = JsonFormat.Shape.STRING)
    private Integer invoiceStatus;

    /** 创建时间 */
    @ApiModelProperty("创建时间")
    @JsonFormat(pattern = "yyyy-MM-dd hh:mm:ss")
    private Date createTime;

//    public static void main(String[] args) throws Exception {
//        String[][] content = new String[][]{{"运单编号", "货物名称", "发货地址", "收货地址", "发货方", "收货方", "出发网点", "运单状态", "创建时间", "结算方式", "应收总额(元)", "实收金额(元)", "应收余额(元)", "结清状态"},
//                {"运单编号", "货物名称运单编号运单编号运单编号运单编号", "收货地址收货地址收货地址收货地址收货地址", "收货方收货方收货方收货方收货方收货方收货方收货方", "发货方11111111111111111", "收货方5555555555555555555", "出发网点", "运单状态", "创建时间", "结算方式", "应收总额(元)", "实收金额(元)", "应收余额(元)", "结清状态"},
//                {"运单编号", "货物名称", "发货地址", "收货地址", "发货方", "收货方", "出发网点", "运单状态", "创建时间", "结算方式", "应收总额(元)", "实收金额(元)", "应收余额(元)", "结清状态"}};
//        drawTable("4月份应收总额；1250，已结算金额：1150，未结算金额：100。已对账 对账人；张会计，对账时间；2021.08.10", content);
//    }
//
//    public static void drawTable(String title, String[][] content) throws Exception {
//        // 创建PDF文档
//        PDDocument document = new PDDocument();
//        PDPage page = new PDPage(new PDRectangle(1500F, 1000F));
//        document.addPage(page);
//        PDType0Font font = PDType0Font.load(document, ResourceUtil.getStream("static/simhei.ttf"));
//        PDPageContentStream contentStream = new PDPageContentStream(document, page);
//        contentStream.setFont(font, 12);
//        // 样式
//        final float y = page.getMediaBox().getWidth() - 550;
//        final float margin = 50;
//        final int rows = content.size();
//        final int cols = content.get(0).size();
////        final float rowHeight = 20f;
//        List<Double> rowHeightList = CollUtil.newArrayList();
//        for (List<String> row : content) {
//            int textLength = 0;
//            for (String col : row) {
//                int length = col.length();
//                if (length > textLength) {
//                    textLength = length;
//                }
//            }
//            rowHeightList.add(Math.ceil(textLength / 8.0) * 20);
//        }
//        final float tableWidth = page.getMediaBox().getWidth() - (2 * margin);
////        final float tableHeight = rowHeight * rows;
//        float tableHeight = 0;
//        final float colWidth = tableWidth / (float) cols;
//        final float cellMargin = 5f;
//        // 标题
//        contentStream.beginText();
//        contentStream.moveTextPositionByAmount(margin, page.getMediaBox().getWidth() - 530);
//        contentStream.drawString(title);
//        contentStream.endText();
//        //draw the rows
//        float nexty = y;
//        for (int i = 0; i <= rows; i++) {
//            contentStream.drawLine(margin, nexty, margin + tableWidth, nexty);
//            if (i != rows) {
//                Double rowHeight = rowHeightList.get(i);
//                tableHeight += rowHeight;
//                nexty -= rowHeight;
//            }
//        }
//        //draw the columns
//        float nextx = margin;
//        for (int i = 0; i <= cols; i++) {
//            contentStream.drawLine(nextx, y, nextx, y - tableHeight);
//            nextx += colWidth;
//        }
//        //now add the text
//        float textx = margin + cellMargin;
//        float texty = y - 15;
//        for (int i = 0; i <= content.size(); i++) {
//            for (String text : content.get(i)) {
//                if (text.length() > 8) {
//                    StringBuilder sb = new StringBuilder(text);
//                    float tempy = texty;
//                    for (int z = 0; z < Math.ceil(sb.length() / 8.0); z++) {
//                        int startIndex = 7 * z, endIndex = startIndex + 7;
//                        contentStream.beginText();
//                        contentStream.moveTextPositionByAmount(textx, tempy);
//                        contentStream.drawString(sb.substring(startIndex, endIndex > sb.length() ? sb.length() - 1 : endIndex));
//                        contentStream.endText();
//                        tempy -= 20;
//                    }
//                } else {
//                    contentStream.beginText();
//                    contentStream.moveTextPositionByAmount(textx, texty);
//                    contentStream.drawString(text);
//                    contentStream.endText();
//                }
//                textx += colWidth;
//            }
//            texty -= rowHeightList.get(i);
//            textx = margin + cellMargin;
//        }
//        contentStream.close();
//        // pdf输出
//        File file = FileUtil.createTempFile("checkBill", ".pdf", true);
//        document.save(file);
//        document.close();
//        System.out.println(file.getAbsolutePath());
//    }

}
